<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>验证码校验</title>
</head>
<style>
    #checkCode{
        color: #ab1111;
        font-size: 30px;
    }



</style>
<body>
    <div>
        <div class="CODE-SHOW">
            <span class="code" id="checkCode">123456</span>
           <a href="" id="fdsafdsa" onclick="getCode()">看不清换一张</a>
            <a href="">----------------------</a>
        </div>
        <div class="INPUT-CODE">
            <label for="INPUT-CODE">验证码：</label>
            <input type="text" id="INPUT-CODE">
            <span id="text_show"></span>
        </div>
        <input  id= "button" type="button" value="确定"/>


    </div>


    
</body>

<script>
   
    window.onload = function(){
    let  abs =  getCode();
    function getCode(){
        let arr = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];
    let str = '';
    for (let i = 0; i < 6; i++) {
        let  num =  Math.round(Math.random()*15);   
        str += arr[num];
        
    }
    return str;
    
}
    document.getElementById('checkCode').innerHTML = abs;
    document.getElementById('fdsafdsa').onclick = function(){
        document.getElementById('checkCode').innerHTML = getCode();

    }
    document.getElementById('button').onclick = function(){
        let code = document.getElementById('checkCode').innerText;
        let code1 = document.getElementById('INPUT-CODE').value;
        if(code != code1){
            alert('您输入的验证码不正确！')
            document.getElementById('INPUT-CODE').value = '';
        }

    }


    }

    



</script>
</html>